<link rel="stylesheet" href="../assets/css/bootstrap.min.css">
<link rel="stylesheet" href="../assets/css/bootstrap-table.css">
<link rel="stylesheet" href="../assets/css/sweetalert.css">
<link rel="stylesheet" href="../assets/css/bootstrapValidator.min.css">
<link rel="stylesheet" href="../assets/css/style.css" />
<style>
</style>
<body style="background-color: #FFFFFF" onload="parent.scrollTo(0, 0);">
<div class="breadcrumbs ace-save-state" id="breadcrumbs">
</div>
<div class="page-content">
    <!--<div class="page-header">
        <h1>

        </h1>
    </div>&lt;!&ndash; /.page-header &ndash;&gt;-->

    <div class="row" style="">
        <div class="col-sm-12">
            <form class="form-inline" id="searchForm" style="padding:2px 5px">
                <div class="form-group">
                    <label>姓名:</label>
                    <input class="form-control" type="text" id="searchTeaName" name="teaName">
                </div>
                &#12288;
                <button type="button" class="btn-sm btn-primary" onclick="searchAll()"><i class="glyphicon glyphicon-search"></i> 搜索
                </button>
            </form>
            <hr>
            <table id="table" class="table-hover table-responsive"
                   data-search="false"
                   data-show-refresh="true"
                   data-show-toggle="true"
                   data-show-export="true"
                   data-minimum-count-columns="2"
                   data-pagination="true"
                   data-unique-id="id"
                   data-page-number="1"
                   data-page-size="10"
                   data-page-list="[10, 20, 30, 40]"
                   data-pagination-pre-text="上一页"
                   data-pagination-next-text="下一页"
                   data-show-footer="false"
                   data-side-pagination="server"
                   data-valign="middle"
                   data-url="/teaStuClaLog/getTeaList"
                   data-query-params="queryParams"
                   data-response-handler="responseHandler">
            </table>
        </div>
    </div><!-- /.row -->
</div><!-- /.page-content -->


</body>
<!-- PAGE CONTENT ENDS -->

<script src="../assets/js/jquery-2.1.4.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/bootstrap-table.js"></script>
<script src="../assets/js/bootstrap-table-export.js"></script>
<script src="../assets/js/bootstrapValidator.min.js"></script>
<script src="../assets/js/tableExport.js"></script>
<script src="../assets/js/bootstrap-table-zh-CN.js"></script>
<script src="../assets/js/sweetalert.min.js"></script>

<script type="text/javascript">
    $(function () {
        $("#table").bootstrapTable({
            height: 600,   //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            showColumns: true, //显示隐藏列
            striped: false,
            columns: [
                {
                    title: '姓名',
                    field: 'teaName',
                    align: 'center',
                    valign: 'middle',
                    sortable: true
                },
                {
                    title: '状态',
                    field: 'stateFormat',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '操作',
                    field: 'operate',
                    align: 'left',
                    valign: 'middle',
                    formatter: operateFormatter
                }
            ]
        });
    });
    function searchAll() {
        $("#table").bootstrapTable('refresh');
    }
    function queryParams(params) {
        return {
            pageSize: params.limit,
            pageNumber: $('#table').bootstrapTable('getOptions').pageNumber,
            sort: params.sort,
            order: params.order,
            teaName: $("#searchTeaName").val()

        };
    }
    function responseHandler(res) {
        return {
            "rows": res.teaLog.list,
            "total": res.teaLog.total
        }
    }
    function operateFormatter(value, row, index) {
        var stateButton = "";
        if(row.state!=null)
            stateButton+='<button class="btn-sm btn-success" onclick="publish(' + row.teaId + ')"><i class="glyphicon glyphicon-refresh"></i> 发布</button>';
        stateButton+='<button class="btn-sm btn-primary" onclick="manageTeaClass(' + row.teaId + ')"><i class="glyphicon glyphicon-calendar"></i> 排课</button>';
        return stateButton;
    }
    function manageTeaClass(teaId) {
        location.href="teacherSchedule.html?teaId="+teaId;
    }
</script>
